function validateInt(obj, booleanNullAllowed, errMsg1, errMsg2)
{
	wrongTmp = '';
	wrongNum = false;

	if (obj.value == '' && booleanNullAllowed == false )
	{
		wrongTmp += errMsg1;		
	}	
	else if ( obj.value != '' )
	{
		var str = obj.value;   
		// Return false if characters are not '0-9'.    
		/*for (var i = 0; i < str.length; i++)
		{      
			var ch = str.substring(i, i + 1);      
			if (ch < "0" || "9" < ch)
			{             
	 			wrongNum = true;
	 			break;
			}
		} 
		*/
		
		var regExp = /\b-?\d+\b/
		if (obj.value.search(regExp) == -1)
		{
			wrongNum = true;
		}
		
		if (wrongNum == true) 
			{
				wrongTmp += errMsg2;
			}			
	}			
	
	if ( wrongTmp != '' && booleanFocus == false) 
	{
		obj.focus();	
		booleanFocus = true;
	}
	
	return wrongTmp;		
}

function validateFloat(obj, booleanNullAllowed, errMsg1, errMsg2)
{
	decSep = false;
	wrongTmp = '';
	wrongNum = false;

	if (obj.value == '' && booleanNullAllowed == false )
	{
		wrongTmp += errMsg1;		
	}	
	else if ( obj.value != '' )

	{
		
		
		var str = obj.value;   	
		var regExp = /[^\d\.,]/
	
		if (str.search(regExp)!=-1)
		{
			wrongNum = true;
		}
		/*
		// Return false if characters are not '0-9' or ',' .    
		for (var i = 0; i < str.length; i++)
		{      
			var ch = str.substring(i, i + 1);      
			if ((ch < "0" || "9" < ch) && ch != ',' && ch != '.' && str != ' ' || str == ',' || str == '.')
			{             
	 			wrongNum = true;
	 			break;
			}
			if ( ch == ',' || ch == '.')
			{
				if ( decSep == true )
				{
					wrongNum = true;
		 			break;
				}
				else
					decSep = true;
			}	
		}  */    
		if (wrongNum == true) 
			{
				wrongTmp += errMsg2;
			}			
	}			
	if ( wrongTmp != '' && booleanFocus == false) 
	{
		obj.focus();	
		booleanFocus = true;
	}
	return wrongTmp;		
}

function validateFloatCommaOnly(obj, booleanNullAllowed, errMsg1, errMsg2)
{
	decSep = false;
	wrongTmp = '';
	wrongNum = false;

	if (obj.value == '' && booleanNullAllowed == false )
	{
		wrongTmp += errMsg1;		
	}	
	else if ( obj.value != '' )

	{
		var str = obj.value;   
		// Return false if characters are not '0-9' or ',' .    
		for (var i = 0; i < str.length; i++)
		{      
			var ch = str.substring(i, i + 1);      
			if ((ch < "0" || "9" < ch) && ch != ',' && ch != '-' || i != 0 && ch == '-')
			{             
	 			wrongNum = true;
	 			break;
			}
			if ( ch == ',' )
			{
				if ( decSep == true )
				{
					wrongNum = true;
		 			break;
				}
				else
					decSep = true;
			}	
		}      
		if (wrongNum == true) 
			{
				wrongTmp += errMsg2;
			}			
	}			
	if ( wrongTmp != '' && booleanFocus == false) 
	{
		obj.focus();	
		booleanFocus = true;
	}
	return wrongTmp;		
}

function validateFloatMod(obj, booleanNullAllowed, errMsg1, errMsg2)
{
	decSep = false;
	wrongTmp = '';
	wrongNum = false;

	if (obj.value == '' && booleanNullAllowed == false )
	{
		wrongTmp += errMsg1;		
	}	
	else if ( obj.value != '' )

	{
		var str = obj.value;   
		// Return false if characters are not '0-9' or ',' .    
		for (var i = 0; i < str.length; i++)
		{      
			var ch = str.substring(i, i + 1);      
			if ((ch < "0" || "9" < ch) && ch != ',' && ch != '.' && ch != '-' || i != 0 && ch == '-')
			{             
	 			wrongNum = true;
	 			break;
			}
			if ( ch == ',' || ch == '.')
			{
				if ( decSep == true )
				{
					wrongNum = true;
		 			break;
				}
				else
					decSep = true;
			}	
		}      
		if (wrongNum == true) 
			{
				wrongTmp += errMsg2;
			}			
	}			
	if ( wrongTmp != '' && booleanFocus == false) 
	{
		obj.focus();	
		booleanFocus = true;
	}
	return wrongTmp;		
}

function validateIntStartEnd(obj1, obj2, booleanNullAllowed1, booleanNullAllowed2, errMsg1, errMsg2, errMsg3, errMsg4)
{
	wrongTmp = '';
		
	wrongTmp += validateInt (obj1, booleanNullAllowed1, errMsg1, errMsg3);
	wrongTmp += validateInt (obj2, booleanNullAllowed2, errMsg2, errMsg3);
	
	if ( wrongTmp == '' )
	{
		if (parseInt(obj1.value) > parseInt(obj2.value))
			{
			wrongTmp += errMsg4;
			obj1.focus();
			booleanFocus = true;
			}
	}
	return wrongTmp;
}

function calculateProfit(cost, objInput, field, LCID)
{
	var wrong = '';
	var obj1Parsed = NumberWebToJs(cost.value, LCID); //parseFloat(cost.value.replace(/,/g, '.'));

	var objInputParsed = NumberWebToJs(objInput.value, LCID); //parseFloat(objInput.value.replace(/,/g, '.'));

	if (!isNaN(obj1Parsed) && !isNaN(objInputParsed))
	{
		if (field == 1)
			{
			
			var result = Math.round(100 * obj1Parsed * (1 + objInputParsed/100))/100;
			}
		else
			{
			if (obj1Parsed == 0)
				return '0';
			var result = (objInputParsed/obj1Parsed - 1) * 100;				
			}		

//		var strresult = NumberJsToWeb((result * 100)/100, LCID, -1);
//	    return strresult //.replace(/\./g, ',');		
		
		return NumberJsToWeb(result, LCID, -1)
	}
	else return '';
}



